//
//  ChainObjects.h
//  Charles
//
//  Created by Leo on 2019/7/1.
//  Copyright © 2019 charles. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
 发生问题的类
 */
@interface Trouble : NSObject

- (instancetype)initWithNumber:(NSInteger)number;

- (NSInteger)number;

- (NSString *)toString;

@end

/**
 用来解决问题的抽象类,它是职责链上的对象
 */
@interface Support : NSObject

@property (nonatomic, weak) Support *next;      // 要推卸给的对象.

- (instancetype)initWithName:(NSString *)name;

- (void)support:(Trouble *)trouble;

- (BOOL)resolve:(Trouble *)trouble;

- (NSString *)toString;

@end

/**
 不解决问题的类
 */
@interface NoSupport : Support

- (instancetype)initWithName:(NSString *)name;

@end

/**
 解决编号小于limit的问题
 */
@interface LimitSupport : Support

- (instancetype)initWithName:(NSString *)name limit:(NSInteger)limit;

@end

/**
 解决奇数编号的问题
 */
@interface OddSupport : Support

- (instancetype)initWithName:(NSString *)name;

@end

/**
 解决指定编号的问题
 */
@interface SpecialSupport : Support

- (instancetype)initWithName:(NSString *)name number:(NSInteger)number;

@end

NS_ASSUME_NONNULL_END
